<include file="header"/>
<body>
<div class="wraper">
    <div class="head clearfix">
        <a href="javascript:window.history.back(-1);" class="iconfont icon-zuojiantou pull-left"></a>
        <span class="head-name pull-left">信息认证</span>
    </div>
    <div class="info-container">
        <div class="form-box">
            <div class="form-list tb-mode">
                <p class="field tb-cell">真实姓名</p>
                <p class="area tb-cell"><input placeholder="请填写您的真实姓名" id="real_name"/></p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">性别</p>
                <p class="area tb-cell">
                    <select id="sex">
                        <option value="0">请选择您的性别</option>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                    <span class="iconfont icon-xiala"></span>
                </p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">手机号码</p>
                <p class="area tb-cell"><input placeholder="请填写您的手机号码" id="tel" name="num"></p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">年龄</p>
                <p class="area tb-cell"><input placeholder="请填写您的年龄" id="user_age" name="num"></p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">陪护类型</p>
                <p class="area tb-cell">
                    <select id="type">
                        <option value="0">请选择陪护类型</option>
                        <option value="1">全职</option>
                        <option value="2">兼职</option>
                    </select>
                    <span class="iconfont icon-xiala"></span>
                </p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">工作开始时间</p>
                <p class="area tb-cell"><input id="beginTime" placeholder="请选择工作开始时间" /></p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">工作结束时间</p>
                <p class="area tb-cell"><input id="endTime" placeholder="请选择工作结束时间" /></p>
            </div>
            <div class="form-list tb-mode">
                <p class="field tb-cell">身份证号</p>
                <p class="area tb-cell"><input placeholder="请填写您的身份证号" id="identity_num"></p>
            </div>
            <div class="form-list">
                <p>上传身份证正反面照片</p>
                <div class="upload-img">
                    <p class="iconfont icon-shangchuantupian"></p>
                    <p>点击上传</p>
                    <input type="file" class="upload-btn" id="identification_image"/>
                </div>
                <div class="cardbox clearfix">
                    <div class="card">
                        <img src="/assets/park/huser/images/default.jpg" id="image1"/>
                        <span class="iconfont icon-del-round"></span>
                    </div>
                    <div class="card">
                        <img src="/assets/park/huser/images/default.jpg" id="image2"/>
                        <span class="iconfont icon-del-round"></span>
                    </div>
                </div>
            </div>
            <div id="datePlugin"></div>
        </div>
    </div>
    <a href="#" class="normal-btn">确认提交</a>
</div>
<input type="hidden" value="" id="isImage_url1">
<input type="hidden" value="" id="isImage_url2">
<input type="hidden" v1="0" v2="0" id="isImage_url">
<div class="pop-box" id="pop-pass">
    <div class="main">
        <p class="iconfont icon-chenggong"></p>
        <div class="main-text">
            <p class="stress text-center">信息已提交</p>
            <p class="text-center">请耐心等待审核</p>
        </div>
    </div>
</div>

<div class="pop-box" id="pop-box">
    <div class="main">
        <p class="iconfont icon-shenheshibai"></p>
        <div class="main-text">
            <p class="text-center">请耐心等待审核</p>
        </div>
    </div>
</div>
<script src="/assets/park/huser/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="/assets/park/huser/js/laydate.js"></script>
<script type="text/javascript">
    $('.icon-del-round').each(function(i){
        $(this).click(function(){
            var res = confirm('是否删除？');
            if(res){
                $('.card:eq('+i+') img').attr('src','/assets/park/huser/images/default.jpg');
                $('#isImage_url'+(i+1)).val('');
                $("#isImage_url").attr('v'+(i+1),0);
            }else{
                return;
            }
        });
    });
</script>
<script type="text/javascript">
    !function(){
        laydate.skin('molv');//切换皮肤，请查看skins下面皮肤库
    }();

    //日期范围限制
    var start = {
        elem: '#beginTime',
        format: 'YYYY-MM-DD',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#endTime',
        format: 'YYYY-MM-DD',
        min: laydate.now(),
        max: '2099-06-16',
        istime: true,
        istoday: false,
        choose: function(datas){
            start.max = datas; //结束日选好后，充值开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
</script>
<script type="text/javascript" src="/assets/bower_components/upload/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/assets/bower_components/upload/jquery.fileupload.js"></script>
<script type="text/javascript" src="/assets/bower_components/upload/jquery.iframe-transport.js"></script>
<script>

    $(".normal-btn").on('click',function(){
        var real_name = $("#real_name").val();
        var sex = $("#sex").val();
        var tel = $("#tel").val();
        var user_age = $("#user_age").val();
        var type = $("#type").val();
        var start_time = $("#beginTime").val();
        var end_time = $("#endTime").val();
        var identity_num = $("#identity_num").val();
        var isImage_url1 = $("#isImage_url1").val();
        var isImage_url2 = $("#isImage_url2").val();

        $.ajax({
            url:'/Park/hkeeper/check/conf_id/1',
            type:'POST',
            dataType:'json',
            data:{real_name:real_name,sex:sex,tel:tel,user_age:user_age,type:type,start_time:start_time,end_time:end_time,identity_num:identity_num,isImage_url1:isImage_url1,isImage_url2:isImage_url2},
            success:function(data){
                if(data.err_code == 200){
                    $("#pop-pass").show();
                    setTimeout('popBox()',2000);
                    setTimeout('goCheck()',2000);
                }else{
                    $("#pop-box").find('.text-center').text(data.message);
                    $("#pop-box").show();
                    setTimeout('popBox()',2000);
                }
            }
        });
    });

    //图片上传
    $("#identification_image").fileupload({
        url: "/Park/hkeeper/uploads/conf_id/1",//文件上传地址，当然也可以直接写在input的data-url属性内
        formData: {param1: "p1", param2: "p2"},//如果需要额外添加参数可以在这里添加
        done: function (e, result) {
            var data = $.parseJSON(result.result);
            if (data.code == 200) {
                var iamgeStatus = $("#isImage_url").attr('v1');
                if(iamgeStatus == 0){
                    $('#image1').attr('src',data.url);
                    $("#isImage_url1").val(data.url);
                    $("#isImage_url").attr('v1','1');
                }else if(iamgeStatus == 1){
                    $('#image2').attr('src',data.url);
                    $("#isImage_url2").val(data.url);
                    $("#isImage_url").attr('v2','1');
                }
            } else {
                //
            }
        }
    });

    function popBox()
    {
        $("#pop-pass").hide();
        $("#pop-box").hide();
    }

    $('input[name=\'num\']').keyup(function(e){
        var tmptxt = $(this).val();     
        $(this).val(tmptxt.replace(/\D|^0/g,''));
    });

    function goCheck()
    {
        location.href="/Park/hkeeper/index/conf_id/1";
    }
</script>
</body>
</html>
